package com.weixin.paleituo.adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.weixin.paleituo.R;
import com.weixin.paleituo.base.BaseRecycleAdapter;
import com.weixin.paleituo.help.RecycleViewHolder;
import com.weixin.paleituo.util.UIUtils;

import java.util.List;

/**
 * Author yichao
 * Time  2018/6/28 13:43
 * Dest  选择社区
 */

public class SelectConnunityMenuRecyclerViewAdapter extends BaseRecycleAdapter<String> {
    private int selectPosition;

    public void setSelectPosition(int selectPosition) {
        this.selectPosition = selectPosition;
    }

    public SelectConnunityMenuRecyclerViewAdapter(Context context, List<String> datas) {
        super(context, datas, R.layout.item_select_connunity_menu_layout);
    }



    @Override
    protected void setData(RecycleViewHolder holder, String s, final int position) {
     TextView textView= holder.getItemView(R.id.tv_name_item_select_connunity_menu_layout);
     textView.setText(s);

     if (selectPosition==position){
         textView.setTextColor(UIUtils.getColor(R.color.c_ffffffff));
         textView.setBackgroundColor(UIUtils.getColor(R.color.c_29CE7E));

     }else {
         textView.setTextColor(UIUtils.getColor(R.color.c_a5a5a5));
         textView.setBackgroundColor(UIUtils.getColor(R.color.c_fff5f5f5));
     }
     textView.setOnClickListener(new View.OnClickListener() {
         @Override
         public void onClick(View v) {
          /*  selectPosition= position;
            notifyDataSetChanged();*/
          if (mOnListener!=null){
              mOnListener.onItemOnClick(position);
          }
         }
     });


    }

    OnListener mOnListener;
    public interface  OnListener{
         void onItemOnClick(int position);
    }
    public void setOnListener(OnListener onListener){
        this.mOnListener=onListener;

    }
}
